
version: '3'

services:
  traefik:
    image: "traefik:v2.4"
    container_name: "traefik"
    command:
      # - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=MY_EMAIL_LETSENCRIPT"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
      # redirect port 80 -> 443
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.web.http.redirections.entrypoint.permanent=true"
    ports:
      - "443:443"
      - "80:80"
      - "8080:8080"
    volumes:
      - "./letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  startpage:
    image: MY_IMAGE
    container_name: startpage
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.startpage.rule=Host(`MY_HOSTNAME`)"
      - "traefik.http.routers.startpage.entrypoints=websecure"
      - "traefik.http.routers.startpage.tls.certresolver=myresolver"
      # use compression
      - "traefik.http.routers.startpage.middlewares=test-compress"
      - "traefik.http.middlewares.test-compress.compress=true"
